<?php
/* Smarty version 3.1.30, created on 2017-11-02 13:06:12
  from "C:\ComsenzEXP\wwwroot\Moodblog\admin\html\editor.html" */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '3.1.30',
  'unifunc' => 'content_59fb1844655bb4_91827907',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '11baa0bd051706c9aa67e7eeb1c4c9cee73c9cc0' => 
    array (
      0 => 'C:\\ComsenzEXP\\wwwroot\\Moodblog\\admin\\html\\editor.html',
      1 => 1509627688,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_59fb1844655bb4_91827907 (Smarty_Internal_Template $_smarty_tpl) {
?>
<!DOCTYPE html>
<html>
<head>
	<link rel="stylesheet" type="text/css" href="./html/common.css" />
    <?php echo '<script'; ?>
 type="text/javascript" charset="utf-8" src="../ueditor/ueditor.config.js"><?php echo '</script'; ?>
>
    <?php echo '<script'; ?>
 type="text/javascript" charset="utf-8" src="../ueditor/ueditor.all.min.js"> <?php echo '</script'; ?>
>
    <?php echo '<script'; ?>
 type="text/javascript" charset="utf-8" src="../ueditor/lang/zh-cn/zh-cn.js"><?php echo '</script'; ?>
>
</head>
<body>
	<div class="content">
	
	<div class = "setTitle">文本编辑</div>
		<div class="editor">
			<div class="left">
			<div class="title1">标题</div>
			<input class="titleInput" id = "title" type="text" placeholder="这里填写博文标题" value="<?php echo $_smarty_tpl->tpl_vars['article']->value['title'];?>
"></input>
			<div class="title1">正文</div>
			 <div id="editor" type="text/plain" style="height:300px">
			 </div>
		      <p >博文封面： <input id="titleimg" type="file" name="file" /><input type="submit" onclick="submitImg()" value="提交"></input>
			
			<div class="thetitleimg">
				当前封面:<span class="titileimgname"><?php if ($_smarty_tpl->tpl_vars['article']->value['titleimg'] != NULL) {
echo $_smarty_tpl->tpl_vars['article']->value['titleimg'];
} else { ?>无<?php }?></span>
				<img class="titileimgname" src="<?php if ($_smarty_tpl->tpl_vars['article']->value['titleimg'] != NULL) {?>../source/picture/<?php echo $_smarty_tpl->tpl_vars['article']->value['titleimg'];
}?>">
			</div>
			<?php echo '<script'; ?>
 type="text/javascript">
				var ue = UE.getEditor('editor');
				ue.ready(function() {
					getArticle(ue);
				});
					function createXmlHttp() {
					  var xmlHttp = null;
					  try {
						xmlHttp = new XMLHttpRequest();
					  } catch (e) {
						try {
						  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
						} catch (e) {
						  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
						}
					  }
					  return xmlHttp;
					}
					  
					function submitForm() {
					  var xmlHttp = createXmlHttp();
					  if('<?php echo $_smarty_tpl->tpl_vars['article']->value;?>
'.length==0)
						var url = './trans.php?action=subarticle';
					  else
						var url = './trans.php?action=uparticle';
					  var postData = new FormData();
					  postData.append('content',ue.getContent());
					  postData.append('title',document.getElementById("title").value);
					  postData.append('artkind',document.getElementById("artkind").value);
					  postData.append('state',document.getElementById("state").value);
					  postData.append('author',document.getElementById("author").value);
					  if(document.getElementsByClassName('titileimgname')[0].innerHTML!='无'){
					  	postData.append('titleimg',document.getElementsByClassName('titileimgname')[0].innerHTML);
					  }
					  if(document.getElementById('top').checked){
						postData.append('istop',"1");
					  }else{
						postData.append('istop',"0");
					  }		
					  if(document.getElementById('banr').checked){
						postData.append('isbanr',"1");
					  }else{
						postData.append('isbanr',"0");
					  }
					  if(document.getElementById('show').checked){
						postData.append('isshow',"1");
					  }else{
						postData.append('isshow',"0");
					  }

					  if(document.getElementById('page').checked){
						postData.append('ispage',"1");
					  }else{
						postData.append('ispage',"0");
					  }

					  if('<?php echo $_smarty_tpl->tpl_vars['article']->value;?>
'.length!=0){
						postData.append('id',"<?php echo $_smarty_tpl->tpl_vars['article']->value['id'];?>
");
					  }
					  if(document.getElementById('date').value)
						postData.append('time',Date.parse(document.getElementById('date').value)/1000);
					  xmlHttp.open("POST", url, true);
					  xmlHttp.onreadystatechange = function() {
						if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
						  if(xmlHttp.responseText == '1') {

							location.replace('article.php?') 
						  }
						 // alert(xmlHttp.responseText);
						}
					  }
					  xmlHttp.send(postData);
					}
					function submitImg(){
						var xmlHttp = createXmlHttp();
						var url = './trans.php?action=subarticleimg';
					 	var postData = "";
					  	var form = new FormData();
					  	form.append("file",document.getElementById("titleimg").files[0]);
					  	xmlHttp.open("POST", url, true);
					  	xmlHttp.onreadystatechange = function() {
						if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {					
						  if(xmlHttp.responseText) {
						  	document.getElementsByClassName('titileimgname')[0].innerHTML = xmlHttp.responseText;
						  	document.getElementsByClassName('titileimgname')[1].src="../source/picture/"+document.getElementsByClassName('titileimgname')[0].innerHTML
						  }
						}
					  }
						xmlHttp.send(form);				
					}
					function getArticle(editor){
						var xmlHttp = createXmlHttp();
						var url = './trans.php?action=getarticletext';
						var form = new FormData();
						form.append("id","<?php echo $_smarty_tpl->tpl_vars['article']->value['id'];?>
")
						xmlHttp.open("POST", url, true);
						xmlHttp.onreadystatechange = function() {
						if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {					
						  if(xmlHttp.responseText){
						  	editor.setContent(xmlHttp.responseText);
						  }
						}
					  }
						xmlHttp.send(form);										
					}
			<?php echo '</script'; ?>
>
			</div>
			<div class="right">
				<button class="pubButton" type='submit' onclick="submitForm('1')"><?php if ($_smarty_tpl->tpl_vars['article']->value) {?>更新<?php } else { ?>发布<?php }?></button>
				<div class="config">
					分类
					<select id="artkind">
						<option value="0" selected>未分类</option>
						<?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['artkindlist']->value, 'value');
if ($_from !== null) {
foreach ($_from as $_smarty_tpl->tpl_vars['value']->value) {
?>
							<?php if ($_smarty_tpl->tpl_vars['value']->value['id'] == $_smarty_tpl->tpl_vars['article']->value['kindid']) {?>
							<option value="<?php echo $_smarty_tpl->tpl_vars['value']->value['id'];?>
" selected><?php echo $_smarty_tpl->tpl_vars['value']->value['name'];?>
</option>
							<?php } else { ?>
							<option value="<?php echo $_smarty_tpl->tpl_vars['value']->value['id'];?>
"><?php echo $_smarty_tpl->tpl_vars['value']->value['name'];?>
</option>
							<?php }?>
						<?php
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl);
?>

					</select>
				</div>
				<div class="config">
					状态
					<select id="state">
						<option value="0" <?php if ($_smarty_tpl->tpl_vars['article']->value['state'] == 0) {?>selected<?php }?>>公开</option>
						<option value="1" <?php if ($_smarty_tpl->tpl_vars['article']->value['state'] == 1) {?>selected<?php }?>>私密</option>
						<option value="2" <?php if ($_smarty_tpl->tpl_vars['article']->value['state'] == 2) {?>selected<?php }?>>草稿</option>
					</select>
				</div>
				<div class="config">
					作者
					<input class="authorInput" id = "author" type="text" value="<?php if ($_smarty_tpl->tpl_vars['article']->value) {
echo $_smarty_tpl->tpl_vars['article']->value['author'];
} else { ?>个快快<?php }?>"></input>
				</div>
				<div class="config">
					日期
					<input type="date" id="date" value="<?php if ($_smarty_tpl->tpl_vars['time']->value) {
echo $_smarty_tpl->tpl_vars['time']->value;
} else {
}?>"></input>
				</div>
				<div class="config">
					<input type="checkbox" class="check" id="top" <?php if ($_smarty_tpl->tpl_vars['article']->value['istop'] == 1) {?>checked<?php }?>>置顶
				</div>
				<div class="config">
					<input type="checkbox" class="check" id="banr" <?php if ($_smarty_tpl->tpl_vars['article']->value['isban'] == 1) {?>checked<?php }?>>禁止评论
				</div>
				<div class="config">
					<input type="checkbox" class="check" id="show" <?php if ($_smarty_tpl->tpl_vars['article']->value['isshow'] == 1) {?>checked<?php }?>>首页展示
				</div>
				<div class="config">
					<input type="checkbox" class="check" id="page" <?php if ($_smarty_tpl->tpl_vars['article']->value['ispage'] == 1) {?>checked<?php }?>>专题模板
				</div>
			</div>
			
		</div>
	
	</div>
</body>
</html><?php }
}
